package net.oschina.app.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.base.BaseAdapter;
import net.oschina.app.bean.CollectBean;
import net.oschina.app.util.CommonUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by wei03 on 2017/1/14.
 */

public class MeFavoriteRvAdapter extends BaseAdapter {

    @Override
    public SoftwareHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(CommonUtils.getContext()).inflate(R.layout.item_collect, parent, false);
        SoftwareHolder softwareHolder = new SoftwareHolder(itemView);
        //将创建的View注册点击事件
        return softwareHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        SoftwareHolder softwareHolder = (SoftwareHolder) holder;
        CollectBean.FavoriteBean softwareBean = (CollectBean.FavoriteBean) mDatas.get(position);
        softwareHolder.mTitleCollect.setText(softwareBean.getTitle());
    }

    static class SoftwareHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.title_collect)
        TextView mTitleCollect;

        SoftwareHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
